home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-12-08 | 32.9 KB | 981 lines | [TEXT/R*ch] |
- C.S.M.P. Digest Thu, 14 Jan 93 Volume 2 : Issue 4
-
- Today's Topics:
-
- Unlocking a locked volume
- How do you draw a circle/oval?
- Fun with WaitNextEvent
- Getting StructureRegion of a dialog. etco
- InsertMenuItem Nasties
-
-
-
- The Comp.Sys.Mac.Programmer Digest is moderated by Michael A. Kelly.
-
- The digest is a collection of article threads from the internet newsgroup
- comp.sys.mac.programmer. It is designed for people who read c.s.m.p. semi-
- regularly and want an archive of the discussions. If you don't know what a
- newsgroup is, you probably don't have access to it. Ask your systems
- administrator(s) for details. If you don't have access to news, there is
- no way that I know of for you to post articles to the group.
-
- Each issue of the digest contains one or more sets of articles (called
- threads), with each set corresponding to a 'discussion' of a particular
- subject. The articles are not edited; all articles included in this digest
- are in their original posted form (as received by our news server at
- cs.uoregon.edu). Article threads are not added to the digest until the last
- article added to the thread is at least one month old (this is to ensure that
- the thread is dead before adding it to the digest). Article threads that
- consist of only one message are generally not included in the digest.
-
- The entire digest is available for anonymous ftp from ftp.cs.uoregon.edu
- [128.223.8.8] in the directory /pub/mac/csmp-digest. Be sure to read the
- file /pub/mac/csmp-digest/README before downloading any files. The most
- recent issues are available from sumex-aim.stanford.edu [36.44.0.6] in the
- directory /info-mac/digest/csmp. If you don't have ftp capability, the sumex
- archive has a mail server; send a message with the text '$MACarch help' (no
- quotes) to LISTSERV@ricevm1.rice.edu for more information.
-
- The digest is also available via email. Just send a note saying that you
- want to be on the digest mailing list to mkelly@cs.uoregon.edu, and you will
- automatically receive each new issue as it is created. Sorry, back issues
- are not available through the mailing list.
-
- Send administrative mail to mkelly@cs.uoregon.edu.
-
-
- -------------------------------------------------------
-
- From: cmcclary@ucs.indiana.edu (Charles McClary)
- Subject: Unlocking a locked volume
- Organization: Indiana University
- Date: Thu, 10 Dec 1992 20:27:42 GMT
-
- I assumed, from reading Inside Mac and Think Reference, that logically
- unlocking a logically locked volume would be as simple as:
-
- void unlock()
- {
- HVolumeParam pb;
- OSErr osErr;
- Str255 volumeName;
- SysEnvRec SysEnvData;
-
- osErr = SysEnvirons(1, &SysEnvData);
-
- pb.ioVRefNum = SysEnvData.sysVRefNum; /* use startup drive */
- pb.ioVolIndex = 0;
- pb.ioNamePtr = volumeName;
- pb.ioCompletion = nil;
-
- osErr = PBHGetVInfo(&pb, false); /* get volume info */
- if (osErr == noErr)
- {
- pb.ioVAtrb &= 0x7FFF; /* set unlock volume bit */
- osErr = PBSetVInfo(&pb, false);
- osErr = FlushVol(0, pb.ioVRefNum);
- }
- }
-
- However, the PBSetVInfo receives a -46 (vLckedErr - Volume is locked),
- which
- makes some sense. What am I missing to correct this?
-
- Thanks in advance,
-
- Charles McClary
- Indiana University
- cmcclary@indiana.edu
-
- +++++++++++++++++++++++++++
-
- From: absurd@apple.apple.com (Tim Dierks, software saboteur)
- Date: 10 Dec 92 22:22:48 GMT
- Organization: MacDTS Marauders
-
- In article <cmcclary-101292152155@mcclary-mac.ucs.indiana.edu>,
- cmcclary@ucs.indiana.edu (Charles McClary) wrote:
- >
- > I assumed, from reading Inside Mac and Think Reference, that logically
- > unlocking a logically locked volume would be as simple as:
- >
- > void unlock()
- > {
- > HVolumeParam pb;
- > OSErr osErr;
- > Str255 volumeName;
- > SysEnvRec SysEnvData;
- >
- > osErr = SysEnvirons(1, &SysEnvData);
- >
- > pb.ioVRefNum = SysEnvData.sysVRefNum; /* use startup drive */
- > pb.ioVolIndex = 0;
- > pb.ioNamePtr = volumeName;
- > pb.ioCompletion = nil;
- >
- > osErr = PBHGetVInfo(&pb, false); /* get volume info */
- > if (osErr == noErr)
- > {
- > pb.ioVAtrb &= 0x7FFF; /* set unlock volume bit */
- > osErr = PBSetVInfo(&pb, false);
- > osErr = FlushVol(0, pb.ioVRefNum);
- > }
- > }
- >
- > However, the PBSetVInfo receives a -46 (vLckedErr - Volume is locked),
- > which
- > makes some sense. What am I missing to correct this?
- >
- > Thanks in advance,
- >
- > Charles McClary
- > Indiana University
- > cmcclary@indiana.edu
-
- Isn't it great? There's no standard way to unlock a software-locked
- volume! The only thing you can do is change the bit manually in the
- volume's entry in the VCB queue, then call _SetVolInfo to make sure
- it gets flushed out to the disk itself.
-
- Fun, huh?
-
- Tim Dierks
- MacDTS. A rose by any other name, Keith.
-
- +++++++++++++++++++++++++++
-
- From: grobbins@Apple.COM (Grobbins)
- Date: 11 Dec 92 00:30:20 GMT
- Organization: Experimental Stuff at Apple
-
- In article <absurd-101292142216@seuss.apple.com> absurd@apple.apple.com (Tim Dierks, software saboteur) writes:
- >Isn't it great? There's no standard way to unlock a software-locked
- >volume! The only thing you can do is change the bit manually in the
- >volume's entry in the VCB queue, then call _SetVolInfo to make sure
- >it gets flushed out to the disk itself. Fun, huh?
-
- No, not fun; it's a bit of a pain. Sample code for unlocking a
- volume is available in the Volume Handling Q&As (available via
- anonymouse ftp from ftp.apple.com in the /dts/mac/tn/files directory.)
-
- Grobbins grobbins@apple.com
-
- Usual disclaimers apply.
-
- +++++++++++++++++++++++++++
-
- From: lkimes@alshain.usc.edu (Lance 'Moof' Kimes)
- Date: 11 Dec 92 04:03:22 GMT
- Organization: University of Southern California, Los Angeles, CA
-
-
- In article <cmcclary-101292152155@mcclary-mac.ucs.indiana.edu>, cmcclary@ucs.indiana.edu (Charles McClary) writes:
- |> I assumed, from reading Inside Mac and Think Reference, that logically
- |> unlocking a logically locked volume would be as simple as:
- |>
- |> void unlock()
- |> {
- |> HVolumeParam pb;
- |> OSErr osErr;
- |> Str255 volumeName;
- |> SysEnvRec SysEnvData;
- |>
- |> osErr = SysEnvirons(1, &SysEnvData);
- |>
- |> pb.ioVRefNum = SysEnvData.sysVRefNum; /* use startup drive */
- |> pb.ioVolIndex = 0;
- |> pb.ioNamePtr = volumeName;
- |> pb.ioCompletion = nil;
- |>
- |> osErr = PBHGetVInfo(&pb, false); /* get volume info */
- |> if (osErr == noErr)
- |> {
- |> pb.ioVAtrb &= 0x7FFF; /* set unlock volume bit */
- |> osErr = PBSetVInfo(&pb, false);
- |> osErr = FlushVol(0, pb.ioVRefNum);
- |> }
- |> }
- |>
- |> However, the PBSetVInfo receives a -46 (vLckedErr - Volume is locked),
- |> which
- |> makes some sense. What am I missing to correct this?
- |>
- |> Thanks in advance,
- |>
- |> Charles McClary
- |> Indiana University
- |> cmcclary@indiana.edu
-
-
- Here is some code I wrote awhile back.
-
- OSErr UnlockHD( short targetVRefNum)
- {
- OSErr Err;
- QHdrPtr VCBQHdrPtr;
- VCB *ssvcb;
-
- Err = nsvErr;
- VCBQHdrPtr = GetVCBQHdr();
- ssvcb = (VCB *)VCBQHdrPtr->qHead;
-
- while((ssvcb != nil) && (ssvcb->vcbVRefNum != targetVRefNum))
- ssvcb = (VCB *)ssvcb->qLink;
-
- if (ssvcb->vcbVRefNum == targetVRefNum)
- {
- if (!BitTst( &ssvcb->vcbAtrb, 0))
- return 0;
- BitClr( &ssvcb->vcbAtrb, 0);
- Err = FlushVol( nil, targetVRefNum);
- }
- return (Err);
- }
-
- It perfectly. Have fun.
-
-
- Lance Kimes
- Systems Programmer
-
- ---------------------------
-
- From: mxmora@unix.sri.com (Matthew Xavier Mora)
- Subject: How do you draw a circle/oval?
- Date: 10 Dec 92 23:41:23 GMT
- Organization: SRI International
-
- Does anybody have code that calculates what pixels to set to draw an
- oval/circle given a rectangle/square not using quickdraw? Filled ovals
- would be nice also.
-
- I need this for my ascii paint program. I got lines and rectangles working
- alrady, I would just like to include ovals in the program too.
-
- Thanks,
- Xavier
-
-
- - ----------------------------------------------------------------------
- Matthew Xavier Mora mxmora@unix.sri.com
- SRI International (415) 859-5011
- (signing Xavier because there are too many Matt's on the net :-))
- - ----------------------------------------------------------------------
-
- +++++++++++++++++++++++++++
-
- From: bwilliam@iat.holonet.net (Bill Williams)
- Organization: HoloNet National Internet Access BBS: 510-704-1058/modem
- Date: Sat, 12 Dec 1992 04:34:04 GMT
-
-
- /*=********************************************************************=*/
-
-
- /*=********************************************************************=*/
- #define INTEGER_32 long int
-
- static void Draw_Filled_Ellipse_Primitive(INTEGER_32 start_X
- , INTEGER_32 start_Y
- ,INTEGER_32 axis_A, INTEGER_32 axis_B
- , PixPatHandle current_Pattern)
- {
- register INTEGER_32 active_X, active_Y;
- register INTEGER_32 axis_A_Squared, axis_B_Squared,
- axis_A_Squared_Times_2;
- register INTEGER_32 axis_B_Squared_Times_2, derivitive_X,
- derivitive_Y, dd;
-
- /* END VAR */
- /*=--------------------------------------------------------------------=*/
- /* Uses dual differential high efficiency technique */
- /*=--------------------------------------------------------------------=*/
-
- active_X = axis_A;
- active_Y = 0;
- axis_A_Squared = axis_A*axis_A;
- axis_B_Squared = axis_B*axis_B;
- axis_A_Squared_Times_2 = axis_A_Squared + axis_A_Squared;
- axis_B_Squared_Times_2 = axis_B_Squared + axis_B_Squared;
- derivitive_X = axis_B_Squared_Times_2*axis_A;
- derivitive_Y = 0L;
- dd = (axis_B_Squared / 4L) - (axis_B_Squared * axis_A) + axis_A_Squared;
-
- /*=--------------------------------------------------------------------=*/
- /* Step along Y axis */
- /*=--------------------------------------------------------------------=*/
- while ( derivitive_X > derivitive_Y ) {
- Draw_Patterned_Eastward_Line_Subprimitive(
- (start_X - active_X)
- , (start_Y - active_Y)
- , (active_X << 1) +1);
-
- Draw_Patterned_Eastward_Line_Subprimitive(
- (start_X - active_X)
- ,(start_Y + active_Y)
- , (active_X << 1) +1);
-
- active_Y +=1;
- derivitive_Y += axis_A_Squared_Times_2;
- if (dd <= 0L )
- dd += (derivitive_Y + axis_A_Squared);
- else {
- derivitive_X -= axis_B_Squared_Times_2;
- active_X -= 1L;
- dd += (derivitive_Y + axis_A_Squared - derivitive_X );
- }
- } /* while ( derivitive_X > derivitive_Y ) */
-
- /*=--------------------------------------------------------------------=*/
- /* Step along X axis */
- /*=--------------------------------------------------------------------=*/
-
- dd += ( ( ((3L *(axis_B_Squared-axis_A_Squared)) / 2L)
- - ( derivitive_X + derivitive_Y ) ) / 2L);
-
- while ( active_X > 0L ) {
- Draw_Patterned_Eastward_Line_Subprimitive(
- (start_X - active_X),(start_Y - active_Y), (active_X << 1) +1);
-
- Draw_Patterned_Eastward_Line_Subprimitive(
- (start_X - active_X),(start_Y + active_Y), (active_X << 1) +1);
-
- active_X -=1;
- derivitive_X -= axis_B_Squared_Times_2;
-
- if (dd > 0L )
- dd += (axis_B_Squared - derivitive_X);
- else {
- derivitive_Y += axis_A_Squared_Times_2;
- active_Y += 1L;
- dd += (derivitive_Y + axis_B_Squared - derivitive_X );
- }
- } /* while ( active_X > 0L ) */
-
- while (active_Y <= axis_B) {
-
- Draw_Patterned_Eastward_Line_Subprimitive(start_X
- ,(start_Y + active_Y)
- , 1L); /* actually only one pixel */
-
- Draw_Patterned_Eastward_Line_Subprimitive(start_X
- ,(start_Y - active_Y)
- , 1L); /* actually only one pixel */
-
- active_Y += 1L;
- }
- } /* Draw_Filled_Ellipse_Primitive */
- /*=********************************************************************=*/
-
-
- /*=********************************************************************=*/
-
-
- I Guarantee this puppy is FAAAAST. I designed it from various sources.
-
- (Draw_Patterned_Eastward_Line_Subprimitive should be written as fast as
- you can make it.... or just make it a LineTo.)
-
-
- Enjoy.
-
- Bill Williams
-
-
- ---------------------------
-
- From: bobert@informix.com (Robert Murphy)
- Subject: Fun with WaitNextEvent
- Date: 8 Dec 92 01:29:40 GMT
- Organization: Informix Software, Inc.
-
- Today's Strange Factoid: WaitNextEvent appears to require QuickDraw
- and/or some of the managers to be initialized. This is not documented
- in any of the references I have immediately available.
-
- I haven't done any experiments to determine exactly *which* managers have
- to be initialized, and probably won't, although if someone knows I'd love
- to hear.
-
- Bob Murphy
- ShadeTree Productions
- Doing an onsite contract at Informix, which is why I have a paucity of
- references.
-
- +++++++++++++++++++++++++++
-
- From: dougm@cns.caltech.edu (Doug McNaught)
- Date: 7 Dec 92 23:03:37
- Organization: The Sinister Icy Black Hand of Death Club
-
- In article <bobert.723778180@godzilla> bobert@informix.com (Robert Murphy) writes:
-
- Today's Strange Factoid: WaitNextEvent appears to require QuickDraw
- and/or some of the managers to be initialized. This is not documented
- in any of the references I have immediately available.
-
- Well, one of its arguments *is* a region...
- [explains the QD requirement, at least]
- - -doug
- - --
- Doug McNaught |"When you start ruling out ideas merely because
- dougm@cns.caltech.edu | they are sheer, gibbering lunacy, you've stopped
- doug@midget.towson.edu | doing science." -Robert Firth in sci.physics
- Nobody approves my opinions! Not even me, sometimes. Read at your own risk.
-
- +++++++++++++++++++++++++++
-
- From: nerm@apple.com (Dean Yu)
- Date: 8 Dec 92 18:25:28 GMT
- Organization: Apple Computer, Inc.
-
- In article <bobert.723778180@godzilla>, bobert@informix.com (Robert Murphy)
- wrote:
- >
- > Today's Strange Factoid: WaitNextEvent appears to require QuickDraw
- > and/or some of the managers to be initialized. This is not documented
- > in any of the references I have immediately available.
- >
- > I haven't done any experiments to determine exactly *which* managers have
- > to be initialized, and probably won't, although if someone knows I'd love
- > to hear.
- >
- > Bob Murphy
- > ShadeTree Productions
- > Doing an onsite contract at Informix, which is why I have a paucity of
- > references.
-
- Well, WaitNextEvent is part of the Event Manager, and to use the Event
- Manager, you need to initialize the Window Manager, and to do that, you
- have to initialize QuickDraw and the Font Manager... Seems perfectly
- logical to me...
-
- - -- Dean Yu
- Blue Meanie, Negative Ethnic Role Model, etc.
- Apple Computer, Inc.
-
- +++++++++++++++++++++++++++
-
- From: d88-jwa@dront.nada.kth.se (Jon Wtte)
- Date: 9 Dec 92 10:07:15 GMT
- Organization: Royal Institute of Technology, Stockholm, Sweden
-
- In <nerm-081292102455@90.10.20.86> nerm@apple.com (Dean Yu) writes:
-
- > Well, WaitNextEvent is part of the Event Manager, and to use the Event
- >Manager, you need to initialize the Window Manager, and to do that, you
- >have to initialize QuickDraw and the Font Manager... Seems perfectly
- >logical to me...
-
- Does this mean a Faceless Background App should call
- InitGraf ( &qd . thePort ) ;
- InitFonts ( ) ;
- InitWindows ( ) ;
-
- just to call WaitNextEvent? Seems illogical to me.
-
- Cheers,
-
- / h+
-
- - --
- -- Jon W{tte, h+@nada.kth.se, Mac Hacker Deluxe --
- This signature is kept shorter than 4 lines in the interests of UseNet
- S/N ratio.
-
- +++++++++++++++++++++++++++
-
- From: chh9@ellis.uchicago.edu (Conrad Halling)
- Date: 9 Dec 92 16:40:03 GMT
- Organization: University of Chicago Computing Organizations
-
- In article <bobert.723778180@godzilla>
- bobert@informix.com (Robert Murphy) writes:
-
- >Today's Strange Factoid: WaitNextEvent appears to require QuickDraw
- >and/or some of the managers to be initialized. This is not documented
- >in any of the references I have immediately available.
-
- >From Inside Macintosh, Volume I, p. 255:
-
- "Before using the Event Manager, you should initialize the Window
- Manager by calling its procedure InitWindows; parts of the Event Manager
- rely on the Window Manager's data structures and will not work properly
- unless those structures have been properly initialized. Initializing
- the Window Manager requires you to have initialized QuickDraw and
- the Font Manager.
- "Assembly-language note: If you want to use events but not windows,
- set the global variable WindowList (a long word) to 0 instead of calling
- InitWindows."
-
-
- - --
- Conrad Halling
- c-halling@uchicago.edu
-
- +++++++++++++++++++++++++++
-
- From: nerm@apple.com (Dean Yu)
- Date: Wed, 9 Dec 1992 20:04:12 GMT
- Organization: Apple Computer, Inc.
-
- In article <1992Dec9.100715.28595@kth.se>, d88-jwa@dront.nada.kth.se (Jon
- Wtte) wrote:
- >
- > In <nerm-081292102455@90.10.20.86> nerm@apple.com (Dean Yu) writes:
- >
- > > Well, WaitNextEvent is part of the Event Manager, and to use the Event
- > >Manager, you need to initialize the Window Manager, and to do that, you
- > >have to initialize QuickDraw and the Font Manager... Seems perfectly
- > >logical to me...
- >
- > Does this mean a Faceless Background App should call
- > InitGraf ( &qd . thePort ) ;
- > InitFonts ( ) ;
- > InitWindows ( ) ;
- >
- > just to call WaitNextEvent? Seems illogical to me.
- >
- > Cheers,
- >
- > / h+
- >
- You can get away with not calling InitWindows() by slamming 0 into the
- WindowList low memory global. This is mentioned in the Event Manager
- chapter of Inside Mac I.
-
- - -- Dean Yu
- Blue Meanie, Negative Ethnic Role Model, etc.
- Apple Computer, Inc.
-
- +++++++++++++++++++++++++++
-
- From: falken@apple.com (Dave Falkenburg)
- Date: 9 Dec 92 21:14:16 GMT
- Organization: Apple Computer, Inc.
-
- In article <nerm-091292120342@90.10.20.86> Dean Yu, nerm@apple.com writes:
- >> > Well, WaitNextEvent is part of the Event Manager, and to use the
- Event
- >> >Manager, you need to initialize the Window Manager, and to do that,
- you
- >> >have to initialize QuickDraw and the Font Manager... Seems perfectly
- >> >logical to me...
- >>
- >> Does this mean a Faceless Background App should call
- >> InitGraf ( &qd . thePort ) ;
- >> InitFonts ( ) ;
- >> InitWindows ( ) ;
- >>
- >> just to call WaitNextEvent? Seems illogical to me.
- >>
- >> Cheers,
- >>
- >> / h+
- >>
- > You can get away with not calling InitWindows() by slamming 0 into the
- >WindowList low memory global. This is mentioned in the Event Manager
- >chapter of Inside Mac I.
-
- Please donnt call InitWindows() inside a faceless background app.
-
- You still need to call InitGraf(), and InitFonts() because of 0(a5) and
- that region thing, and some TrueType font caching stuff.
-
- - -Dave Falkenburg
- - -Apple Computer, Inc.
-
- +++++++++++++++++++++++++++
-
- From: Quinn <quinn@cs.uwa.edu.au>
- Organization: The University of Western Australia
- Date: Thu, 10 Dec 1992 01:07:40 GMT
-
- In article <1992Dec9.100715.28595@kth.se> Jon Wtte,
- d88-jwa@dront.nada.kth.se writes:
- >Does this mean a Faceless Background App should call
- > InitGraf ( &qd . thePort ) ;
- > InitFonts ( ) ;
- > InitWindows ( ) ;
-
- It does have to call *InitGraf* at least under MultiFinder 6.
- MultiFinder has a cow if any application doesn't have a proper A5
- world including QD globals (yes even faceless background ones).
-
- Exercise for the brave... get a copy of MultiFinder 6 and disassemble
- its _NMInstall patches. Notice how MultiFinder samples the
- application's (A5) and puts it into MultiFinder's (A5). Worry
- about what would happen if (A5) was not valid (ie you hadn't called
- InitGraf).
-
- Quinn "The Eskimo!" <quinn@cs.uwa.edu.au> "Support HAVOC!"
- Department of Computer Science, The University of Western Australia
- -- Who spent *days* debugging that one!
-
- +++++++++++++++++++++++++++
-
- From: d88-jwa@dront.nada.kth.se (Jon Wtte)
- Date: 9 Dec 92 21:59:47 GMT
- Organization: Royal Institute of Technology, Stockholm, Sweden
-
- In <nerm-091292120342@90.10.20.86> nerm@apple.com (Dean Yu) writes:
-
- > You can get away with not calling InitWindows() by slamming 0 into the
- >WindowList low memory global. This is mentioned in the Event Manager
- >chapter of Inside Mac I.
-
- Ah, but I mistrust lo-mem globals by pure training.
-
- Say, when a faceless app "mode" was added, why not a documented
- trap to do this without hassle? Just a suggestion...
-
- Cheers,
-
- / h+
-
- - --
- -- Jon W{tte, h+@nada.kth.se, Mac Hacker Deluxe --
-
- There's no problem that can't be solved using brute-force algorithms
- and a sufficiently fast computer. Ergo, buy more hardware.
-
- +++++++++++++++++++++++++++
-
- From: mtc@henry.ece.cmu.edu (Magnetic Technology Center)
- Organization: Electrical and Computer Engineering, Carnegie Mellon
- Date: Thu, 10 Dec 1992 03:35:46 GMT
-
- d88-jwa@dront.nada.kth.se (Jon Wtte) writes:
- >nerm@apple.com (Dean Yu) writes:
- >
- >> Well, WaitNextEvent is part of the Event Manager, and to use the Event
- >>Manager, you need to initialize the Window Manager, and to do that, you
- >>have to initialize QuickDraw and the Font Manager... Seems perfectly
- >>logical to me...
- >
- >Does this mean a Faceless Background App should call
- > InitGraf ( &qd . thePort ) ;
- > InitFonts ( ) ;
- > InitWindows ( ) ;
- >
- >just to call WaitNextEvent? Seems illogical to me.
-
- the above snippet _is_ illogical, in this case. IM-I Event Manager
- covers this nicely. here, initializing the window manager should be
- interpreted as setting WindowList to nil and not calling InitWindows()!
- then again, perhaps InitWindows() could check for FBO and do the right
- thing in that situation (adding even more system version dependences).
- apps.
-
- -dave-
- mtc@henry.ece.cmu.edu
-
- +++++++++++++++++++++++++++
-
- From: bobert@informix.com (Robert Murphy)
- Date: 11 Dec 92 01:24:01 GMT
- Organization: Informix Software, Inc.
-
- d88-jwa@dront.nada.kth.se (Jon Wtte) writes:
-
- >In <nerm-081292102455@90.10.20.86> nerm@apple.com (Dean Yu) writes:
-
- >> Well, WaitNextEvent is part of the Event Manager, and to use the Event
- >>Manager, you need to initialize the Window Manager, and to do that, you
- >>have to initialize QuickDraw and the Font Manager... Seems perfectly
- >>logical to me...
-
- >Does this mean a Faceless Background App should call
- > InitGraf ( &qd . thePort ) ;
- > InitFonts ( ) ;
- > InitWindows ( ) ;
-
- >just to call WaitNextEvent? Seems illogical to me.
-
- Well, since I started this thread, I've been doing some digging around...
-
- In a recent issue of Develop, there's an article on faceless background apps
- called "Be My Guest", in which C.K. Haun says:
-
- >Writing an FBA is simple. An FBA is a subset of a standard Macintosh
- >application, consisting of a minimal event loop and the code to handle two
- >types of events, null events and high-level events. No other events are sent
- >to an FBA. This makes a great deal of sense, since every other event
- >(keystroke, mouse click, and such) is designed for foreground applications.
-
- <stuff deleted>
-
- >As you can see, there's not much there. The first thing you'll notice is that
- >an FBA doesn't start up any managers. All the managers you normally start are
- >based on user interface actions. Thus, they should not be called in an FBA-in
- >fact, calling them will cause your FBA to crash. There's one exception to this
- >rule: you can initialize QuickDraw, but only to provide yourself with off-
- >screen grafPorts or to use some QuickDraw functions. Do not do any actual
- >screen drawing from an FBA.
-
- So... according to this article, an FBA doesn't have to initialize any
- managers. I presume this information is correct, so I guess maybe an app
- that doesn't have "background-only" set in the size resource is different
- from an FBA?
-
- - - Bob Murphy
-
- +++++++++++++++++++++++++++
-
- From: grobbins@Apple.COM (Grobbins)
- Date: 12 Dec 92 22:48:50 GMT
- Organization: Experimental System Software Department
-
- In article <bobert.724037041@godzilla> bobert@informix.com (Robert Murphy) writes:
- >In a recent issue of Develop, there's an article on faceless background apps
- >called "Be My Guest", in which C.K. Haun says: ...
- >
- >So... according to this article, an FBA doesn't have to initialize any
- >managers. I presume this information is correct, so I guess maybe an app
- >that doesn't have "background-only" set in the size resource is different
- >from an FBA?
-
- No, the article is not entirely correct. A faceless background app
- (AKA background-only app) definitely should call InitGraf; indeed, any
- app which uses the Apple Event Manager should call InitGraf (since the
- Apple event manager uses QuickDraw's Random function.) An FBA must have
- both the canBackground and backgroundOnly bits set; by definition,
- that makes it an FBA.
-
- An upcoming tech note ("Background-Only Applications") will try to
- address gotchas of FBAs and correct and supplement the New Inside
- Macintosh information. (Other gotchas: the default stack for an FBA
- is only 2K; you cannot set an arbitrary stack, but rather SetApplLimit
- enforces a 24K minimum on color machines; routines which might
- sometimes raise dialogs can kill FBAs; launch order vis-a-vis the
- Finder is strange; use of the Notification Manager has HI implications
- because the user may not know the FBA is running.) Sample code is
- available via anonymous ftp from ftp.apple.com (see
- /dts/mac/sc/snippets/interapp.comm/smalldaemon.hqx.)
-
-
- Grobbins grobbins@apple.com
-
- Usual disclaimers apply.
-
- ---------------------------
-
- From: ttak@quads.uchicago.edu (toki takeuchi)
- Subject: Getting StructureRegion of a dialog. etco
- Date: 13 Dec 92 01:29:06 GMT
- Organization: University of Chicago Computing Organizations
-
- I want to get the StructureRegion of a dialog before I display
- the dialog. I.e., I want to get the rectangle of the entire
- window, including the window structure before the dialog is displayed.
-
- I've tried getting the DialogPeek's structure region's boundary
- box for an invisible dialog (before the dialog is displayed, with
- the Initially Visible flag off in its DLOG resource), but
- until I call ShowWindow, its structure region's rect remains
- as (0,0,0,0).
-
- I want to do this because I want to position a dialog in System 6
- according to the auto-position feature of System 7. System 7
- seems to position the dialog depending on the rect of the
- WDEF and not the grafport portrect. Anyone at Apple know the
- secret???
-
- Thanks a lot!
-
- Kenji Takeuchi (please respond directly, preferably).
-
- +++++++++++++++++++++++++++
-
- From: ttak@quads.uchicago.edu (toki takeuchi)
- Organization: University of Chicago Computing Organizations
- Date: Sun, 13 Dec 1992 01:22:52 GMT
-
-
-
- +++++++++++++++++++++++++++
-
- From: absurd@apple.apple.com (Tim Dierks, software saboteur)
- Date: 13 Dec 92 22:30:12 GMT
- Organization: MacDTS Marauders
-
- In article <1992Dec13.012906.18671@midway.uchicago.edu>,
- ttak@quads.uchicago.edu (toki takeuchi) wrote:
- > I want to get the StructureRegion of a dialog before I display
- > the dialog. I.e., I want to get the rectangle of the entire
- > window, including the window structure before the dialog is displayed.
- >
- > I've tried getting the DialogPeek's structure region's boundary
- > box for an invisible dialog (before the dialog is displayed, with
- > the Initially Visible flag off in its DLOG resource), but
- > until I call ShowWindow, its structure region's rect remains
- > as (0,0,0,0).
- >
- > I want to do this because I want to position a dialog in System 6
- > according to the auto-position feature of System 7. System 7
- > seems to position the dialog depending on the rect of the
- > WDEF and not the grafport portrect. Anyone at Apple know the
- > secret???
-
- The structure region generally doesn't get calculated until you
- display the window. You can get the WDEF to figure them out if
- you call it manually, but there's a better solution for this case;
- just move the dialog way off screen and display it behind the
- other windows (so you don't affect the highlighting of your
- windows); you can then examine the structure region, etc, so
- you can determine where to put your dialog.
-
- > Kenji Takeuchi (please respond directly, preferably).
-
- (I emailed this too.)
- (OK, well, not yet, but soon.)
-
- Tim Dierks
- MacDTS, pinball addict
-
- ---------------------------
-
- From: duga@pacvax.UUCP (Brady Duga)
- Subject: InsertMenuItem Nasties
- Date: 10 Dec 92 20:53:58 GMT
- Organization: Pacer Software Inc., Westborough, MA USA
-
- I don't think I've seen this question before (though my net access has been
- shaky recently), so here goes...
-
- I want to add items to a menu that contain the "/" character. InsertMenuItem
- and AppendMenu parse this as meaning the next character is a command key
- equiv. But I don't want that. I want the character to appear. Does anyone
- have an idea how to work around this? I need to create the menu on the fly, so
- pre-creating it with ResEdit isn't a solution...
-
- - --Brady (duga@pacersoft.com)
-
-
-
- +++++++++++++++++++++++++++
-
- From: absurd@apple.apple.com (Tim Dierks, software saboteur)
- Date: 10 Dec 92 22:57:01 GMT
- Organization: MacDTS Marauders
-
- In article <1831@pacvax.UUCP>, duga@pacvax.UUCP (Brady Duga) wrote:
- >
- > I don't think I've seen this question before (though my net access has been
- > shaky recently), so here goes...
- >
- > I want to add items to a menu that contain the "/" character. InsertMenuItem
- > and AppendMenu parse this as meaning the next character is a command key
- > equiv. But I don't want that. I want the character to appear. Does anyone
- > have an idea how to work around this? I need to create the menu on the fly, so
- > pre-creating it with ResEdit isn't a solution...
- >
- > --Brady (duga@pacersoft.com)
-
- When you're dynamically creating menus, the safest way to do it is
- to append an innocuous menu item (such as "New Item"), then use
- SetItem() to change its text to the actual text you desire. Because
- SetItem() doesn't parse the name for the metacharacters, you won't
- have the problem you're having.
-
- A similar problem is that all strings starting with "-" will appear
- as dashed lines, rather than menu items. Because this is actually
- done by the MDEF, it can't be worked around with SetItem; if you want
- the hyphen to appear as the first character, there are a couple of
- options; either change it to an en-dash, which looks pretty similar
- (character $D0, or type option-- (option-hyphen) or insert an invisible
- character before the hyphen to fool the MDEF. A null character (hex
- $00) is good because it's blank and zero-width, but because it's used
- as the delimiter for C strings, you may need to be careful.
-
- Tim Dierks
- MacDTS, but I speak for myself
-
- +++++++++++++++++++++++++++
-
- From: haynes@mace.cc.purdue.edu (Carl W. Haynes III)
- Date: 11 Dec 92 00:39:57 GMT
- Organization: Purdue University
-
- In article <1831@pacvax.UUCP> duga@pacvax.UUCP (Brady Duga) writes:
- >I want to add items to a menu that contain the "/" character. InsertMenuItem
- >and AppendMenu parse this as meaning the next character is a command key
- >equiv. But I don't want that. I want the character to appear. Does anyone
- >have an idea how to work around this? I need to create the menu on the fly, so
- >pre-creating it with ResEdit isn't a solution...
-
- SetItem doesn't interpret the special characters, so first AppendMenu with
- an empty string, then SetItem with your string:
-
- AppendMenu(menuHdl, "\p ");
- SetItem(menuHdl, menuNum, menuStr);
-
-
- carl
-
-
- - --
- Carl W. Haynes III || hcs@applelink.apple.com
- Haynes Consulting Services || haynes@mace.cc.purdue.edu
- Macintosh Programming and Consulting || ** AVAILABLE **
-
- +++++++++++++++++++++++++++
-
- From: jcav@ellis.uchicago.edu (JohnC)
- Date: 10 Dec 92 22:41:53 GMT
- Organization: The Royal Society for Putting Things on Top of Other Things
-
- In article <1831@pacvax.UUCP> duga@pacvax.UUCP (Brady Duga) writes:
- >I want to add items to a menu that contain the "/" character. InsertMenuItem
- >and AppendMenu parse this as meaning the next character is a command key
- >equiv. But I don't want that. I want the character to appear. Does anyone
- >have an idea how to work around this? I need to create the menu on the fly, so
- >pre-creating it with ResEdit isn't a solution...
-
-
- Use _InsertMenuItem or _AppendMenu to create an item consisting only of the
- letter "x". Then use _SetItem to change the text of this newly-created item
- from "x" to the item string you really wanted (containing meta-characters
- galore if you so desire).
-
- - --
- John Cavallino | EMail: jcav@midway.uchicago.edu
- University of Chicago Hospitals | John_Cavallino@uchfm.bsd.uchicago.edu
- Office of Facilities Management | USMail: 5841 S. Maryland Ave, MC 0953
- B0 f++ c+ g++ k s++ e+ h- pv | Chicago, IL 60637
-
- +++++++++++++++++++++++++++
-
- From: keith@taligent.com (Keith Rollin)
- Organization: Taligent
- Date: Fri, 11 Dec 1992 01:00:54 GMT
-
- In article <1831@pacvax.UUCP>, duga@pacvax.UUCP (Brady Duga) wrote:
- >
- > I don't think I've seen this question before (though my net access has been
- > shaky recently), so here goes...
- >
- > I want to add items to a menu that contain the "/" character. InsertMenuItem
- > and AppendMenu parse this as meaning the next character is a command key
- > equiv. But I don't want that. I want the character to appear. Does anyone
- > have an idea how to work around this? I need to create the menu on the fly, so
- > pre-creating it with ResEdit isn't a solution...
-
- SetItem does not interpret the meta-characters. Therefore:
-
- AppendMenu(menuHandle, "dummy");
- SetItem(menuHandle, CountMItems(menuHandle), "Real/Text");
-
- Make sure that the string you pass to AppendMenu is not empty, or
- AppendMenu will ignore it.
-
- - -----
- Keith Rollin
- Phantom Programmer
- Taligent, Inc.
-
- ---------------------------
-
- End of C.S.M.P. Digest
- **********************
-